
<template>
  <div class="recommendRoot">
    <div class="recommendInfo flex">
      <img src="/src/assets/img/recommendMusic.png" />
      <div class="title">
        <div class="titleTag">每日歌曲推荐</div>
        <div class="content">根据你的音乐口味生成，每天6:00更新</div>
      </div>
    </div>
    <div class="btns flex">
      <div class="btnItem flex playAll">
        <i class="iconfont icon-bofang "></i> 播放全部
      </div>
      <div class="btnItem flex">
        <i class="iconfont icon-xihuan "></i> 收藏全部
      </div>
    </div>
    <!-- <detail-table /> -->
  </div>

</template>

<script>
import { reactive, onMounted } from 'vue'
import { reqRecommendSongs } from '@/network/api'
import { useRouter } from 'vue-router'
import { handleMusicTime } from '@/plugins/utils'
import DetailTable from '@/components/detailTable/DetailTable.vue'
export default {
  name: 'recommend',
  components: { DetailTable },
  props: {},
  setup() {
    const data = reactive({
      recommendList: []
    })
    const router = useRouter()
    const getRecommendSongs = async () => {
      let res = await reqRecommendSongs()
      console.log(res)
      console.log(res.code)
      if (res.code !== 200) {
        console.log(' router.replace ')
        router.replace('/discover')
        return
      }
      res = res.data.dailySongs
      data.recommendList = res.map(v => {
        v.dt = handleMusicTime(v.dt)
        return v
      })
    }
    onMounted(() => {
      getRecommendSongs()
    })
    return {}
  }
}
</script>

<style scoped>
.recommendRoot {
  width: 100%;
  height: 100%;
}
.recommendInfo {
  padding: 20px 20px;
}
.titleTag {
  font-size: 19px;
  font-weight: 600;
  color: #000;
  margin: 3px 0;
}
.content {
  font-size: 12px;
}
.recommendInfo img {
  width: 90px;
}
.btns {
  font-size: 12px;
  margin-left: 30px;
}
.btnItem {
  padding: 8px 15px;
  border: 1px solid #ccc;
  border-radius: 20px;
  margin-right: 10px;
}
.btns i {
  margin-right: 3px;
}
.playAll {
  color: #fff;
  background-color: var(--red);
}
</style>